"""
功能描述：维护公共方法，方便其他模块调用
导包
创建类
床架初始化方法
接收driver
创建实例方法
实现上滑下滑等

"""

# 导包
import time
from  appium代码第一周.common.log import log1
# 创建类
class publib():
    # 床架初始化方法
    def __init__(self,driver):
        # 接收driver
        self.driver =driver
        # 创建实例方法
    def get_ping(self):
            # 实现上滑下滑等
        x=self.driver.get_window_size()['width']
        y=self.driver.get_window_size()['height']

    # 上滑
    def statul(self):
        size=self.get_ping()
        x1=size[0]*0.5
        y1=size[1]*0.75
        y2=size[1]*0.15
        self.driver.swipe(x1,y1,x1,y2)
        log1.info('上滑完成')

    # 下滑
    def statuk(self):
        size=self.get_ping()
        x1=size[0]*0.5
        y1=size[1]*0.15
        y2=size[1]*0.75
        self.driver.swipe(x1,y1,x1,y2)
        log1.info('下滑完成')
    # 左滑
    def statuj(self):
        size = self.get_ping()
        x1 = size[0] * 0.05
        y1 = size[1] * 0.5
        x2 = size[1] * 0.75
        self.driver.swipe(x1, y1, x2, y1)
        log1.info('左滑完成')
    # 右滑
    def statuh(self):
        size = self.get_ping()
        x1 = size[0] * 0.75
        y1 = size[1] * 0.5
        x2 = size[1] * 0.05
        self.driver.swipe(x1, y1, x2, y1)
        log1.info('右滑完成')

if __name__ == '__main__':
    from appium代码第一周.common.driver import driver
    w=driver.startup()
    p=publib(w)
    p.statuj()